#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int romanToInt(char* s)
{
	int x = 0;
	while (*s)
	{
		switch (*s)
		{
		case 'I':
			if (*(s + 1) == 'V')
			{
				x = x + 4;
				s++;
			}
			else if (*(s + 1) == 'X')
			{
				x = x + 9;
				s++;
			}
			else
				x = x + 1;
			break;
		case 'V':
			x = x + 5;
			break;
		case 'X':
			if (*(s + 1) == 'L')
			{
				x = x + 40;
				s++;
			}
			else if (*(s + 1) == 'C')
			{
				x = x + 90;
				s++;
			}
			else
				x = x + 10;
			break;
		case 'L':
			x = x + 50;
			break;
		case 'C':
			if (*(s + 1) == 'D')
			{
				x = x + 400;
				s++;
			}
			else if (*(s + 1) == 'M')
			{
				x = x + 900;
				s++;
			}
			else
				x = x + 100;
			break;
		case 'D':
			x = x + 500;
			break;
		case 'M':
			x = x + 1000;
			break;
		}
		s++;
	}
	return x;
}
int main()
{
	printf("%d", romanToInt("MCMXCIV"));

	return 0;
}